<template>
  <div>
    <Table :columns="tableColumns"
           :data="tableData"></Table>
  </div>
</template>

<script>
import { getUserList } from '@/api/user';

export default {
  data () {
    return {
      tableData: [],
      tableColumns: [
        {
          type: 'index',
          width: 60,
          align: 'center'
        },
        {
          title: '姓名',
          key: 'name',
          align: 'center'
        },
        {
          title: '年龄',
          key: 'age',
          align: 'center'
        }
      ]
    };
  },
  created () {
    this.init();
  },
  methods: {
    async init () {
      (await getUserList()).forEach(list => {
        this.tableData.push(JSON.parse(list));
      });
      console.log(this.tableData);
    }
  }
};
</script>

<style scoped>
</style>
